#pragma once
#include <vector>
#include <memory>
#include <map>


__interface IWin
{
public:
	virtual void OnInit(void* hwnd,int viewid) = NULL;
	virtual void OnUpdate() = NULL;
	virtual void OnExit() = NULL;
	virtual bool OnMsgProc(void* hwnd, unsigned int msg, unsigned __int64 wparam, unsigned __int64 lparam);
	virtual void OnResize(int w, int h) = NULL;
};
__interface IMainWin:public IWin
{
	virtual void OnFinalUpdate() = NULL;
};

struct windowstate
{
public:
	std::shared_ptr<IWin> win;
	int viewid;
};

class winmgr
{
public:
	void MainLoop();
	void CreateMainWin(const char* title, int w, int h, int nCmdShow, std::shared_ptr<IWin> winprocess);
	void CreateWin(const char* title, int w, int h, std::shared_ptr<IWin>  winprocess);
	void ResetSubWin();
	static winmgr* Instance();
protected:
	winmgr();
	std::map<void*, windowstate> mapwins;
	void* handleMainWin = nullptr;
	static winmgr* g_this;
	int GetFreeID();
	void OnExitWin(void* hwnd);
};

